void main(List<String> args) {
  /*
  Circle circle = Circle();
  circle.name = '圆';
  circle.show();
  circle.r = 2;
  circle.showArea();
  */
  //print(circle.area());
  /*
  Rect rect = Rect(10.9 , 13.8);
  rect.name = '长方形';
  rect.show();
  print(rect.area);
  */
  Shape r = Rect(10.8 , 11.2);
  r.name = '矩形';
  //r.w = 10.11;  //w在shape中没有这个属性，报错
  if(r is Rect){  //判断r是否为Rect类型
    r.w = 10.11 ;
  }

  (r as Rect).w = 22.1;
  r.show();
}
/*
*父类
**/
class Shape {
  String name = '形状';
  void show(){
    print(name);
  }
  void showArea(){
    print('面积');
  }
}
/**
 * 子类
 * 圆
 */
class Circle extends Shape {
  double r = 1.0;
  double area(){
    return 3.14*r*r;
  }
  @override  //重写（覆写）方法
  void showArea(){
    super.show();
    super.showArea();
    print('圆的面积为' + this.area().toString());
  }
}

/**
 * 矩形
 */
class Rect extends Shape{
  double w = 1.0;
  double h = 2.0;
  Rect(this.w,this.h);
  get area{
    return this.w*this.h;
  } //使用访问器
  @override
  void show(){
    print(this.name+'宽：'+this.w.toString()+'高：'+this.h.toString()
    +'面积：'+this.area.toString());
  }
}